package edu.gym4all.service.domain;

import android.os.Parcel;
import android.os.Parcelable;
import edu.gym4all.service.CardioExercise;
import edu.gym4all.service.ExerciseEnum;

public class Cardio implements CardioExercise, Parcelable {

	private ExerciseEnum exercise;

	// Time in minutes
	int time = 0;

	public Cardio(ExerciseEnum exercise, int time) {
		this.exercise = exercise;
		this.time = time;
	}

	public Cardio(Parcel source) {
		this.readFromParcel(source);
	}

	@Override
	public ExerciseEnum getExercise() {
		return this.exercise;
	}

	@Override
	public int getTime() {
		return this.time;
	}

	@Override
	public void setTime(int time) {
		this.time = time;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeParcelable(this.exercise, flags);
		dest.writeInt(this.time);
	}

	public static final Parcelable.Creator<Cardio> CREATOR = new Parcelable.Creator<Cardio>() {

		@Override
		public Cardio createFromParcel(Parcel source) {
			return new Cardio(source);
		}

		@Override
		public Cardio[] newArray(int size) {
			return new Cardio[size];
		}
	};

	private void readFromParcel(Parcel in) {
		this.exercise = in.readParcelable(ExerciseEnum.class.getClassLoader());
		this.time = in.readInt();
	}

	@Override
	public String toString() {
		return this.getExercise().getExerciseName();
	}
}